package com.dongpu.springboot.rabbitmq.web.controller;

import com.dongpu.springboot.rabbitmq.config.MQSender;
import com.dongpu.springboot.rabbitmq.pojo.Address;
import com.dongpu.springboot.rabbitmq.rabbit.MsgProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author biyuyang
 */
@RestController
@RequestMapping("/rabbit")
public class RabbitController {

	@Autowired
	private MQSender mqSender;

	@RequestMapping(value = "/update",method = RequestMethod.GET)
	public void update(){
		Address bo = new Address();
		bo.setAddress("测试update地址的啊");
		mqSender.update(bo);
	}

	@RequestMapping(value = "/insert",method = RequestMethod.GET)
	public void insert(){
		Address bo = new Address();
		bo.setAddress("测试insert地址的啊");
		mqSender.insert(bo);
	}

	@RequestMapping(value = "/delete",method = RequestMethod.DELETE)
	public void delete(){
		Address bo = new Address();
		bo.setAddress("测试delete地址的啊");
		mqSender.delete(bo);
	}

	@Autowired
	private MsgProducer msgProducer;

	@RequestMapping(value = "/sendmsg",method = RequestMethod.GET)
	public void sendmsg(){
		msgProducer.sendMsg("点对点的消息发送");
	}

	@RequestMapping(value = "/sendAll",method = RequestMethod.GET)
	public void sendAll(){
		msgProducer.sendAll("这是群发的消息,ABC三个队列接受消息");
	}
}
